package com.example.rpc_core.loadbalance;

import com.example.rpc_core.loadbalance.impl.RandomLoadBalancer;
import com.example.rpc_core.loadbalance.impl.RoundRobinLoadBalancer;
import com.example.rpc_core.spi.SpiLoader;

public class LoadBalancerFactory {

    static{
        SpiLoader.load(LoadBalancer.class);
    }

    /**
     * 默认负载均衡器
     */
    private static final LoadBalancer DEFAULT_LOAD_BALANCE = new RoundRobinLoadBalancer();
    /**
     * 获取对应的实例
     * @param name
     * @return
     */
    public static LoadBalancer getLoadBalancer(String name){

        return SpiLoader.getInstance(LoadBalancer.class, name);
    }
}
